package com.ffcs.crmd.tsp.server.util;

import java.io.IOException;
import java.net.SocketException;

import org.apache.commons.net.telnet.TelnetClient;

public class TelnetHelper {
    
    public static boolean telnet(String ipAddress, int port) {
        try {
            TelnetClient telnet = new TelnetClient();
            telnet.connect(ipAddress, port);
            return true;
        } catch (Throwable e) {
            e.printStackTrace();
        }
        return false;
    }
    
    public static boolean telnet(String ipAddress, int port, int connectTimeout) {
        try {
            TelnetClient telnet = new TelnetClient();
            telnet.setConnectTimeout(connectTimeout);
            telnet.connect(ipAddress, port);
            return true;
        } catch (Throwable e) {
            e.printStackTrace();
        }
        return false;
    }
    
    public static void main(String[] args) throws SocketException, IOException {
        System.out.println(TelnetHelper.telnet("134.129.67.23", 47392));
    }
}
